package com.happyfamily.springboot.crowdsourcingplatform.dao.weng;

import com.happyfamily.springboot.crowdsourcingplatform.model.LastestInfomation;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface LastInfomationDao
{

	/**
	 * 批量插入数据
	 *
	 * @param list
	 * @return
	 */
	int save(@Param("list") List<LastestInfomation> list);

	@Select("select count(*) from latest_information")
	Long countAllLastInfos();

	@Select("select * from latest_information order by tips1 desc limit #{startPosition},#{limit}")
	List<LastestInfomation> getAllLastInfosByPage(Integer startPosition, Integer limit);

	@Delete("delete from latest_information where lid = #{lid}")
	int deleteLatestInfo(Integer lid);

	@Update("update latest_information set lwho = '管理员',ltime = curdate() where lid = #{lid}")
	int openLatestInfo(Integer lid);

	@Update("update latest_information set lwho = '',ltime = '' where lid = #{lid}")
	int closeLatestInfo(Integer lid);

	Long getInfoByFuzzy(String ltitle, String getDate);

	List<LastestInfomation> getInfoByFuzzyPage(String ltitle, String getDate, Integer startPosition, Integer limit);

	@Update("update latest_information set ltitle = #{ltitle} where lid = #{lid}")
	int infoEdit(Integer lid, String ltitle);

	@Select("select * from latest_information order by ltime desc limit 0,10")
	List<LastestInfomation> frontGetLatestNews();
}
